/**
 * Copyright &copy; 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.thinkgem.jeesite.modules.inventory.service;

import java.util.Date;
import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.service.CrudService;
import com.thinkgem.jeesite.modules.inventory.entity.HostLinks;
import com.thinkgem.jeesite.modules.inventory.dao.HostLinksDao;

/**
 * 连接Service
 * @author johnKee
 * @version 2016-08-30
 */
@Service
@Transactional(readOnly = true)
public class HostLinksService extends CrudService<HostLinksDao, HostLinks> {

	public HostLinks get(String id) {
		return super.get(id);
	}

	public HostLinks getByFromHostidAndToHostid(HostLinks hostLinks){
		return dao.getByFromHostidAndToHostid(hostLinks);
	}
	
	public List<HostLinks> findList(HostLinks hostLinks) {
		return super.findList(hostLinks);
	}
	
	public Page<HostLinks> findPage(Page<HostLinks> page, HostLinks hostLinks) {
		return super.findPage(page, hostLinks);
	}
	
	@Transactional(readOnly = false)
	public void save(HostLinks hostLinks) {
		HostLinks oldLink = getByFromHostidAndToHostid(hostLinks);
		if(oldLink != null){
			oldLink.setThruTime(hostLinks.getFromTime());
			super.save(oldLink);
		}
		super.save(hostLinks);
	}
	
	@Transactional(readOnly = false)
	public void delete(HostLinks hostLinks) {
		super.delete(hostLinks);
	}
	
}